package com.yanqu.road.logic.config.beautyescort;

import com.yanqu.road.entity.beautyescort.EscortBeautyCartNPCInfo;
import com.yanqu.road.entity.beautyescort.EscortDartTypeInfo;
import com.yanqu.road.entity.beautyescort.rank.EscortWeekRewardInfo;
import com.yanqu.road.entity.enums.eItemId;
import com.yanqu.road.logic.config.GameConfig;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class BeautyEscortConfig {

    /**
     * 解析镖车机器人
     */
    public static Map<Integer, EscortBeautyCartNPCInfo>  parseCartNPCInfo(){
        Map<Integer, EscortBeautyCartNPCInfo> tempCartNPCInfoMap = new ConcurrentHashMap<>();
        List<String> robotsList = StringUtils.stringToStringList(GameConfig.ESCORT_ROBOTS_CONFIG, "\\|");
        for (String robotsStr : robotsList) {
            List<String> paramList = StringUtils.stringToStringList(robotsStr, "-");
            if(paramList.size() < 6){
                return tempCartNPCInfoMap;
            }
            EscortBeautyCartNPCInfo cartNPCInfo = new EscortBeautyCartNPCInfo();
            cartNPCInfo.setId(Integer.valueOf(paramList.get(0)));
            cartNPCInfo.setType(Integer.valueOf(paramList.get(1)));
            cartNPCInfo.setGlamour(Integer.valueOf(paramList.get(2)));
            cartNPCInfo.setBeautyList(StringUtils.stringToIntegerList(paramList.get(3), ";"));
            cartNPCInfo.setWeight(Integer.valueOf(paramList.get(4)));
            cartNPCInfo.setClientId(Integer.valueOf(paramList.get(5)));
            tempCartNPCInfoMap.put(cartNPCInfo.getId(), cartNPCInfo);
        }
        return tempCartNPCInfoMap;
    }

    /**
     * 解析镖车类型
     */
    public static Map<Integer, EscortDartTypeInfo> parseDartTypeInfo(String config){
        Map<Integer, EscortDartTypeInfo> tempDartTypeInfoMap = new ConcurrentHashMap<>();
        List<String>  dartTypeStrList = StringUtils.stringToStringList(config, "\\|");
        int size = dartTypeStrList.size();
        for(int i = 0; i < size; i++){
            List<String> paramList = StringUtils.stringToStringList(dartTypeStrList.get(i), "-");
            EscortDartTypeInfo typeInfo = new EscortDartTypeInfo();
            typeInfo.setId(i);
            typeInfo.setConsume(paramList.get(0));
            typeInfo.setTakeTime(Integer.parseInt(paramList.get(1)));
            typeInfo.setRewards(paramList.get(2));
            tempDartTypeInfoMap.put(i, typeInfo);
        }
        return tempDartTypeInfoMap;
    }

    /**
     * 初始周榜单奖励
     */
    public static List<EscortWeekRewardInfo> initRankRewardInfo(String configStr) {
        List<EscortWeekRewardInfo> tempRankRewardList = new ArrayList<>();
        List<String> rewardsList = StringUtils.stringToStringList(configStr, "\\|");
        if(rewardsList.size() == 0){
            return null;
        }
        for(String rewards : rewardsList){
            EscortWeekRewardInfo rewardInfo = new EscortWeekRewardInfo();
            List<String> rewardList = StringUtils.stringToStringList(rewards, "#");
            if(rewardList.size() == 0){
                //return false;
            }
            if(rewardList.size() > 0){
                List<String> strList = StringUtils.stringToStringList(rewardList.get(0), ",");
                if(strList.size() != 3){
                    return null;
                }
                rewardInfo.setMin(Integer.valueOf(strList.get(0)));
                rewardInfo.setMax(Integer.valueOf(strList.get(1)));
                rewardInfo.setRewards(strList.get(2));
            }
            if(rewardList.size() > 1){
                List<String> strList = StringUtils.stringToStringList(rewardList.get(1), ",");
                if(strList.size() != 2){
                    return null;
                }
                rewardInfo.setVal(Long.valueOf(strList.get(0)));
                rewardInfo.setAddRewards(strList.get(1));
            }
            tempRankRewardList.add(rewardInfo);
        }
        return tempRankRewardList;
    }

    /**
     * 劫镖次数购买消耗
     */
    public static List<Integer> getFightBuyConsume(){
        return StringUtils.stringToIntegerList(GameConfig.ESCORT_FIGHT_TIMES_RECOVER_CONSUME_CONFIG, ";");
    }
}
